<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jQuery.min.js"></script>
</head>

<body>
    <script>
        $(function () {
            var targetObj = {
                mag: {
                    sex: "niu"
                }
            };
            var obj = {
                uname: "andy",
                sex: "男",
                msg: {
                    age: 18,
                }
            }
            //浅拷贝
            // $.extend(targetObj, obj);
            // // console.log(targetObj);
            // // console.log(obj);
            // targetObj.msg.age = 20;
            // console.log(obj);
            // console.log(targetObj);
            //深拷贝
            $.extend(true, targetObj, obj);
            // console.log(targetObj);
            // console.log(obj);
            targetObj.msg.age = 20;
            console.log(obj);
            console.log(targetObj);
        })
    </script>
</body>

</html>